#include <iostream>
using namespace std;

// Class representing a node in the binary tree
class Node {
public:
    int value;
    Node* left;
    Node* right;

    Node(int value) {
        this->value = value;
        this->left = nullptr;
        this->right = nullptr;
    }
};

// Binary Tree class
class BinaryTree {
public:
    Node* root;

    // Method to insert nodes
    void insert(int value) {
        root = insertRecursive(root, value);
    }

private:
    Node* insertRecursive(Node* current, int value) {
        if (current == nullptr) {
            current = new Node(value);
            return current;
        }

        if (value < current->value) {
            current->left = insertRecursive(current->left, value);
        } else if (value > current->value) {
            current->right = insertRecursive(current->right, value);
        }

        return current;
    }

public:
    // Method for in-order traversal
    void inorderTraversal(Node* node) {
        if (node != nullptr) {
            inorderTraversal(node->left);
            cout << node->value << " ";
            inorderTraversal(node->right);
        }
    }

    // Destructor to free memory
    ~BinaryTree() {
        deleteTree(root);
    }

    void deleteTree(Node* node) {
        if (node == nullptr) return;
        deleteTree(node->left);
        deleteTree(node->right);
        delete node;
    }
};

// Test case to insert nodes and print the in-order traversal
int main() {
    BinaryTree tree;
    tree.insert(50);
    tree.insert(30);
    tree.insert(20);
    tree.insert(40);
    tree.insert(70);
    tree.insert(60);
    tree.insert(80);

    cout << "In-order traversal of the binary tree:" << endl;
    tree.inorderTraversal(tree.root);
    cout << endl;

    return 0;
}
